
package com.craterhill.java.ems.service.impl;

import java.sql.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.craterhill.java.ems.common.beans.Position;
import com.craterhill.java.ems.dao.PositionDao;
import com.craterhill.java.ems.service.PositionService;

@Service
public class PositionServiceImpl implements PositionService {

	@Autowired
	private PositionDao positionDao;

	@Override
	public Position savePosition(Position position) {
		int newPositionId = positionDao.save(position);
		position.setPositionId(newPositionId);
		return position;
	}

	@Override
	public boolean updatePosition(Position position) {
		position.setModifiedDate(new Date(System.currentTimeMillis()));
		return positionDao.update(position);
	}

	@Override
	public boolean deletePosition(Integer... positionIds) {
		return positionDao.remove(positionIds);
	}

	@Override
	public List<Position> getPositions() {
		return positionDao.findAll();
	}

	@Override
	public Position getPosition(int positionId) {
		return positionDao.find(positionId);
	}
}
